<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 4.2.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/logo.jpg">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/logo.jpg">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/logo.jpg">
  <link rel="mask-icon" href="/images/logo.jpg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"www.doubeecat.ga","root":"/","scheme":"Gemini","version":"7.8.0","exturl":false,"sidebar":{"position":"right"},"copycode":{"enable":true,"show_result":true,"style":"flat"},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.xml"};
  </script>

  <meta name="description" content="前言：本文主要是听了洛谷夏令营的网课后做的一些数论笔记,难度大致在提高左右,想获得最好的观看体验,建议您准备好纸笔,手动推一下公式加深印象。">
<meta property="og:type" content="article">
<meta property="og:title" content="数论入门">
<meta property="og:url" content="https://www.doubeecat.ga/2020/08/04/Mathgetstarted/index.html">
<meta property="og:site_name" content="Doubeecat&#39;s Blog">
<meta property="og:description" content="前言：本文主要是听了洛谷夏令营的网课后做的一些数论笔记,难度大致在提高左右,想获得最好的观看体验,建议您准备好纸笔,手动推一下公式加深印象。">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2020-08-04T07:02:49.000Z">
<meta property="article:modified_time" content="2020-08-05T12:25:39.440Z">
<meta property="article:author" content="Doubeecat">
<meta property="article:tag" content="数论">
<meta property="article:tag" content="数学">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="https://www.doubeecat.ga/2020/08/04/Mathgetstarted/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>数论入门 | Doubeecat's Blog</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">Doubeecat's Blog</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">“即便前路混沌，同她走过，才算人间。”</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/aboutme/" rel="section"><i class="fa fa-user fa-fw"></i>关于</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a>

  </li>
        <li class="menu-item menu-item-2020-届招新">

    <a href="/new-oier-wanted/" rel="section"><i class="fa fa-calendar fa-fw"></i>2020 届招新</a>

  </li>
  </ul>
</nav>




</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>
  <div class="reading-progress-bar"></div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://www.doubeecat.ga/2020/08/04/Mathgetstarted/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/logo.jpg">
      <meta itemprop="name" content="Doubeecat">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Doubeecat's Blog">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          数论入门
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2020-08-04 15:02:49" itemprop="dateCreated datePublished" datetime="2020-08-04T15:02:49+08:00">2020-08-04</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2020-08-05 20:25:39" itemprop="dateModified" datetime="2020-08-05T20:25:39+08:00">2020-08-05</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/" itemprop="url" rel="index"><span itemprop="name">学习笔记</span></a>
                </span>
            </span>

          
            <span class="post-meta-item" title="阅读次数" id="busuanzi_container_page_pv" style="display: none;">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span id="busuanzi_value_page_pv"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="far fa-comment"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2020/08/04/Mathgetstarted/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2020/08/04/Mathgetstarted/" itemprop="commentCount"></span>
    </a>
  </span>
  
  <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="far fa-file-word"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>2.3k</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="far fa-clock"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>2 分钟</span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <p>前言：本文主要是听了洛谷夏令营的网课后做的一些数论笔记,难度大致在提高左右,想获得最好的观看体验,建议您准备好纸笔,手动推一下公式加深印象。</p>
<a id="more"></a>
<h2 id="整除"><a href="#整除" class="headerlink" title="整除"></a>整除</h2><p>若 $a = bk$,其中 $a, b, k$ 都是整数,则 $b$ 整除 $a$,记做 $b|a$。</p>
<p>也称 $b$ 是 $a$ 的约数（因数）,$a$ 是 $b$ 的倍数</p>
<h3 id="性质："><a href="#性质：" class="headerlink" title="性质："></a>性质：</h3><ul>
<li><p>$1$ 整除任何数,任何数都整除 $0$</p>
</li>
<li><p>若 $a|b, a|c$,则 $a|(b + c), a|(b − c)$<br>(证明：$b = b’a,c = c’a$ 然后就随便弄了)</p>
</li>
<li><p>若 $a|b$,则对任意整数 $c$,$a|bc$</p>
</li>
<li><p>传递性：若 $a|b, b|c$,则 $a|c$</p>
</li>
</ul>
<hr>
<h2 id="质数与合数"><a href="#质数与合数" class="headerlink" title="质数与合数"></a>质数与合数</h2><p>若大于 $1$ 的正整数 $p$ 仅有两个因子 $1,p$,则称 $p$ 是一个质数（素数）。</p>
<p>否则,若 $p &gt; 1$,则称 $p$ 是一个合数。</p>
<p><strong>1 不是质数也不是合数</strong></p>
<p>若 $n$ 是一个合数,则 $n$ 至少有 $1$ 个质因子。因此其中最小的质因子一定不大于 $\sqrt{n}$</p>
<p>质数有无穷多个。不大于 $n$ 的质数约有 $\frac{n} {\ln n}$ 个。</p>
<p>唯一分解定理：把正整数 n 写成质数的乘积</p>
<p>（即 $n = p_1 ^ {c_1} p_2^{c_2}p_3^{c_3} \dots p_k ^ {c_k}$,其中 pi 为质数且单调不减）,</p>
<p>这样的表示是唯一的。</p>
<hr>
<h2 id="质因数分解"><a href="#质因数分解" class="headerlink" title="质因数分解"></a>质因数分解</h2><p>观察到 $n$ 最多只有 1 个大于 $\sqrt{n}$ 的质因子</p>
<p>直接 $O(\sqrt{n})$ 枚举即可</p>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">factor</span><span class="params">(<span class="keyword">int</span> x)</span> </span>&#123;</span><br><span class="line">    <span class="keyword">int</span> tot = <span class="number">0</span>;</span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">2</span>;i * i &lt;= x;++i) &#123;</span><br><span class="line">        <span class="keyword">if</span> (x % i == <span class="number">0</span>) fac[++tot] = i;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">if</span> (x != <span class="number">1</span>) fac[++tot] = x;</span><br><span class="line">    <span class="keyword">return</span> ;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<hr>
<h2 id="带余除法、同余"><a href="#带余除法、同余" class="headerlink" title="带余除法、同余"></a>带余除法、同余</h2><p>对于$a,b (a,b \in  \mathbb{Z},b &gt; 0)$ ,存在唯一的 $q,r(q,r \in  \mathbb{Z})$ </p>
<p>满足 $a = bq + r$,其中 $0 \leq r &lt; b$ </p>
<p>我们把 $q$ 称为商,$r$ 称为余数</p>
<p>余数可以用 $a \mod b(a \% b)$来表示。</p>
<p>若两数 $a,b$ 除以 $c$ 的余数相等,则称 $a,b$ 模 $c$ 同余,记作 $a \equiv b (\mod c)$</p>
<h3 id="性质"><a href="#性质" class="headerlink" title="性质"></a>性质</h3><p>$a \equiv b (\mod c)$ 与 $c | (a - b)$ 等价</p>
<h3 id="推论"><a href="#推论" class="headerlink" title="推论"></a>推论</h3><p>若 $a \equiv b (\mod c),d | c$ 则 $a \equiv b (\mod d)$</p>
<hr>
<h2 id="最大公约数-Greatest-Common-Divisor"><a href="#最大公约数-Greatest-Common-Divisor" class="headerlink" title="最大公约数(Greatest Common Divisor)"></a>最大公约数(Greatest Common Divisor)</h2><p>设 $a, b$ 是不都为 0 的整数,$c$ 为满足 $c|a$ 且 $c|b$ 的最大整数,则称 $c$ 是 $a, b$ 的最大公约数</p>
<p>记为 $\gcd(a, b)$ 或 $(a, b)$</p>
<p>类似地可以定义多个数的最大公约数</p>
<p>求 GCD 的一般公式：质因数分解</p>
<script type="math/tex; mode=display">
\begin{aligned}
    &a = p_1^{c_1}p_2^{c_2}\dots p_k^{c_k}\\
    &b = p_1^{d_1}p_2^{d_2}\dots p_k^{d_k}\\
    &(a,b) = p_1^{\min{c_1,d_1}}p_2^{\min{c_2,d_2}} \dots p_k^{\min{c_k,d_k}}
\end{aligned}</script><h3 id="性质：-1"><a href="#性质：-1" class="headerlink" title="性质："></a>性质：</h3><script type="math/tex; mode=display">
\begin{aligned}
    &(a, a) = (0, a) = a \\
    &\text{if } a|b,\text{then }  (a, b) = a \\
    &(a, b) = (a, a + b) = (a, ka + b) \\
    &(ka, kb) = k·(a, b) \\ 
    &(a, b, c) = ((a, b), c) 
\end{aligned}</script><p>若 $(a, b) = 1$,则称 $a, b$ 互质（互素）</p>
<p>互质的两个数往往有很好的性质</p>
<hr>
<h2 id="欧几里得算法"><a href="#欧几里得算法" class="headerlink" title="欧几里得算法"></a>欧几里得算法</h2><p>又称辗转相除法</p>
<p>迭代求两数 gcd 的做法</p>
<p>由 $(a, b) = (a, ka + b)$ 的性质：$(a, b) = (b, a \mod b)$</p>
<p>时间复杂度 $O(\log \max{a,b})$</p>
<p>如何证明？每次递归 $b$ 的范围缩小一半,也就是说要证明 $a \mod b \leq \frac{a}{2}$</p>
<p>分类讨论一手：</p>
<script type="math/tex; mode=display">
\begin{aligned}
    &1.b \leq \frac{a}{2}\\
    &\Rightarrow a \mod b < b \leq \frac{a}{2}\\
    &2.a > b > \frac{a}{2} \\
    &\Rightarrow a \mod b = a - b \leq \frac{a}{2}
\end{aligned}</script><hr>
<h2 id="裴蜀定理"><a href="#裴蜀定理" class="headerlink" title="裴蜀定理"></a>裴蜀定理</h2><p>设 $(a, b) = d$,则对任意整数 $x, y$,有 $d|(ax + by)$ 成立</p>
<p>特别地,一定存在 $x, y$ 满足 $ax + by = d$</p>
<p>等价的表述：不定方程 $ax + by = c (a,b,c \in  \mathbb{Z})$有解的充要条件为 $(a, b)|c$</p>
<p>推论：$a, b$ 互质等价于 $ax + by = 1$ 有解</p>
<h3 id="证明"><a href="#证明" class="headerlink" title="证明"></a>证明</h3><p>显然有 $d | a,d | b$</p>
<p>根据之前的引理有 $d | ax,d | by$</p>
<p>故 $d | (ax+by)$</p>
<p>对于第二个结论（以下转自<a href="https://oi-wiki.org/math/bezouts/" target="_blank" rel="noopener">OI Wiki</a>）</p>
<p>若任何一个等于 $0$ , 则 $\gcd(a,b)=a$ . 这时定理显然成立。</p>
<p>若 $a,b$ 不等于 $0$ .</p>
<p>由于 $\gcd(a,b)=\gcd(a,-b)$ ,</p>
<p>不妨设 $a,b$ 都大于 $0$ , $a\geq b,\gcd(a,b)=d$ .</p>
<p>对 $ax+by=d$ , 两边同时除以 $d$ , 可得 $a_1x+b_1y=1$ , 其中 $(a_1,b_1)=1$ .</p>
<p>转证 $a_1x+b_1y=1$ .</p>
<p>我们先回顾一下辗转相除法是怎么做的,由 $\gcd(a, b) \rightarrow \gcd(b,a\mod b) \rightarrow …$ 我们把模出来的数据叫做 $r$ 于是,有</p>
<script type="math/tex; mode=display">\gcd(a_1,b_1)=\gcd(b_1,r_1)=\gcd(r_1,r_2)=\cdots=(r_{n-1},r_n)=1</script><p>把辗转相除法中的运算展开,做成带余数的除法,得</p>
<script type="math/tex; mode=display">
\begin{aligned}
    a_1 &= q_1b+r_1 &(0\leq r_1<b_1) \\
    b_1 &= q_2r_1+r_2 &(0\leq r_2<r_1) \\ 
    r_1 &= q_3r_2+r_3 &(0\leq r_3<r_2) \\ 
    &\cdots \\
    r_{n-3} &= q_{n-1}r_{n-2}+r_{n-1} \\
    r_{n-2} &= q_nr_{n-1}+r_n \\
    r_{n-1} &= q_{n+1}r_n
\end{aligned}</script><p>不妨令辗转相除法在除到互质的时候退出则 $r_n=1$ 所以有（ $q$ 被换成了 $x$ ,为了符合最终形式）</p>
<script type="math/tex; mode=display">r_{n-2}=x_nr_{n-1}+1</script><p>即</p>
<script type="math/tex; mode=display">1=r_{n-2}-x_nr_{n-1}</script><p>由倒数第三个式子 $r_{n-1}=r_{n-3}-x_{n-1}r_{n-2}$ 代入上式,得</p>
<script type="math/tex; mode=display">1=(1+x_nx_{n-1})r_{n-2}-x_nr_{n-3}</script><p>然后用同样的办法用它上面的等式逐个地消去 $r_{n-2},\cdots,r_1$ ,</p>
<p>可证得 $1=a_1x+b_1y$ . 这样等于是一般式中 $d=1$ 的情况。</p>
<hr>
<h2 id="Exgcd"><a href="#Exgcd" class="headerlink" title="Exgcd"></a>Exgcd</h2><p>由裴蜀定理可得,方程 $ax + by = \gcd(a,b)$ 必有一组解。</p>
<p>所以我们考虑如何求出这样的方程的一组解。</p>
<h3 id="证明："><a href="#证明：" class="headerlink" title="证明："></a>证明：</h3><p>设 </p>
<script type="math/tex; mode=display">
\begin{aligned}
    &ax_1 + by_1 = \gcd(a,b) \\
    &bx_2 + (a \mod b)y_2 = \gcd(b,a \mod b) 
\end{aligned}</script><p>则</p>
<script type="math/tex; mode=display">
\begin{aligned}
    &\because \gcd(a,b) = \gcd(b,a \mod b)\\
    &\therefore ax_1 + by_1 = bx_2 + (a \mod b)y_2 \\
    &\because (a \mod b ) = a - (\lfloor \frac{a}{b} \rfloor \times b)\\
    &\therefore ax_1 + by_1 = bx_2 + (a-\lfloor \frac{a}{b} \rfloor \times b) y_2 \\
\end{aligned}</script><p>展开得</p>
<script type="math/tex; mode=display">
\begin{aligned}
    &ax_1 + by_1 = ay_2 + bx_2 - \lfloor \frac{a}{b} \rfloor by_2 = &ay_2 + b(x_2 - \lfloor \frac{a}{b} \rfloor y_2)\\
    &\because a = a,b = b \\
    &\therefore x_1 = y_2 , y_1 = x_2 - \lfloor \frac{a}{b} \rfloor y_2
\end{aligned}</script><p>所以就可以递归求解了。</p>
<h3 id="代码"><a href="#代码" class="headerlink" title="代码"></a>代码</h3><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">exgcd</span><span class="params">(<span class="keyword">int</span> a,<span class="keyword">int</span> b,<span class="keyword">int</span> &amp;x,<span class="keyword">int</span> &amp;y)</span> </span>&#123;</span><br><span class="line">    <span class="keyword">if</span> (!b)  &#123;</span><br><span class="line">        x = <span class="number">1</span>,y = <span class="number">0</span>;</span><br><span class="line">        <span class="keyword">return</span> ;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">int</span> q = a / b;</span><br><span class="line">    exgcd(b,a%b,y,x);</span><br><span class="line">    x = y;</span><br><span class="line">    y = y - q * x;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h3 id="拓展"><a href="#拓展" class="headerlink" title="拓展"></a>拓展</h3><p>考虑形如 $ax + by = c (a,b,c \in  \mathbb{Z})$ 的方程的所有解</p>
<p>首先由裴蜀定理得,不定方程 $ax + by = c (a,b,c \in  \mathbb{Z})$有解的充要条件为 $(a, b)|c$ 。</p>
<p>先考虑求一组特殊解的情况：首先将 $a,b,c$ 都除以 $\gcd(a,b)$ 得 $a_0x + b_0y = c_0$</p>
<p>此时 $\gcd(a_0,b_0) = 1$,所以我们可以求出 $a_0x + b_0y = 1$ 的一组解 $x_0,y_0$ ,则原方程的一组特解为</p>
<script type="math/tex; mode=display">x_1 = \frac{x_0c}{\gcd(a,b)},y_1 = \frac{y_0c}{\gcd (a,b)}</script><p>然后我们考虑构造所有解的形式：</p>
<p>设有 $d (d \in \mathbb{Q})$ 那么必有 $a(x_1 + db) + b(y_1 - da) = c$</p>
<p>同时,这组解需要保证 $db,da \in  \mathbb{Z}$</p>
<p>令当 $d$ 取到最小可能的正值的 $d_x = db,d_y = da$ ,那么任意解中这两个变量与 $x_1,x_2$ 的偏差一定分别是 $d_x,d_y$ 的倍数。</p>
<p>显然,最小的时候 $d_x = \frac{b}{\gcd (a,b)},d_y = \frac{-a}{\gcd (a,b)}$</p>
<p>所有解就是 $x = x_0 + kd_x,y = y_0 + kd_y (k \in  \mathbb{Z})$</p>
<hr>
<h2 id="逆元"><a href="#逆元" class="headerlink" title="逆元"></a>逆元</h2><p>若 $ax \equiv 1 (\mod b)$,则称 $x$ 是 $a$ 关于模 $b$ 的逆元,</p>
<p>常记做 $a^{-1}$。</p>
<p>回忆同余的性质。上式等价于 $ax + by = 1$ </p>
<p>如何求逆元？等价于解方程 $ax + by = 1$</p>
<p>因此逆元不一定存在：存在的充要条件为 $\gcd (a, b) = 1$</p>
<p>推论：$p$ 是质数,$p$ 不整除 $a$,则 $a$ 模 $p$ 的逆元存在。</p>
<p>结论：在 $[0,b)$ 的范围内,若存在 $a$ 关于 $b$ 的逆元,则它是唯一的。</p>
<p>证明：反证法,若存在 2 个 $a$ 关于 $b$ 的逆元,设其为 $x_1,x_2$,不妨假设 $0 &lt; x_1 &lt; x_2 &lt; b$ </p>
<p>也就是说 $ax_1 \equiv ax_2 \equiv 1 (\mod b)$</p>
<p>可以得出 $b | a(x_2 - x_1)$ ,由于 $\gcd(a,b) = 1$,所以 $b | (x_2 - x_1)$</p>
<p>也就是有 $0 \leq (x_2 - x_1) &lt; b$ , 所以不成立。</p>
<h3 id="求逆元"><a href="#求逆元" class="headerlink" title="求逆元"></a>求逆元</h3><p>我们刚才说求逆元等价于解方程 $ax + by = 1$,所以直接 <code>exgcd</code> 求解。</p>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">inv</span><span class="params">(<span class="keyword">int</span> a,<span class="keyword">int</span> b)</span> </span>&#123;</span><br><span class="line">    <span class="keyword">int</span> x,y;</span><br><span class="line">    exgcd(a,b,x,y);</span><br><span class="line">    <span class="keyword">return</span> x;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>这样求单个逆元的复杂度是 $O(\log n)$。</p>
<p>如何 $O(n)$ 求 $1\dots n$ 模质数 $p$ 的逆元？</p>
<ul>
<li><p>方法一：递推</p>
<p>  假设现在要求 $i$ 的逆元  </p>
<p>  考虑带余除法,设 $p = iq + r$,则有 $iq + r \equiv 0(\mod p)$</p>
<p>  注意到 $p$ 是质数,因此 $r \not = {0}$,$r$ 的逆元存在</p>
<p>  等式两边乘 $i^{−1}r^{−1}$,得到 $qr^{−1} + i^{−1} \equiv 0(\mod p)$</p>
<p>  因此 $i−1 \equiv −qr^{−1} \equiv -\frac{p}{i}(p \mod i)^{−1}(\mod p)$</p>
<p>  注意这里如果直接算 $-\frac{p}{i}$ 会产生负数,然后 $p -\frac{p}{i} \equiv -\frac{p}{i} (\mod p)$,所以这么算就不会出问题</p>
<p>  代码</p>
  <figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">int</span> inv[N];</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">prework</span><span class="params">(<span class="keyword">int</span> n)</span> </span>&#123;</span><br><span class="line">    inv[<span class="number">1</span>] = <span class="number">1</span>;</span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">2</span>;i &lt;= n;++i) &#123;</span><br><span class="line">        inv[i] = (p - p / i) * inv[p % i] % p;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></li>
<li>方法二：倒推</li>
</ul>
<p>例题：组合数取模 1</p>
<blockquote>
<p>回答 $T$ 次询问</p>
<p>每次询问 $C(n, k) \mod 998244353$(一个质数)</p>
<p>$T ≤ 10^5$, $0 \leq k \leq n \leq 10^7$</p>
</blockquote>
<p>分析：$C(n, k) = n!/(k!(n − k)!)$</p>
<p>线性求逆,预处理 $n!$ 以及 $n! ^ {-1}$ </p>
<p>$O(1)$ 回答询问</p>
<hr>
<h2 id="线性同余方程"><a href="#线性同余方程" class="headerlink" title="线性同余方程"></a>线性同余方程</h2><p>形如 $ax \equiv c(\mod b)$ 的方程,称为线性同余方程。</p>
<p>等价于 $ax + by = c$ 因此有解条件为 $\gcd(a, b)|c$</p>
<p>若 $\gcd(a, b) = 1$,则 $x$ 有唯一解 $x ≡ a^{-1}c(\mod b)$。</p>
<p>否则设 $(a, b) = d, a = a^{\prime}d, b = b^{\prime}d, c = c’d$</p>
<p>那么有 $a’x + b’y = c’$,即 $a’x \equiv c’(\mod b’)$</p>
<p>这里 $(a’, b’) = 1$,因此有 $x ≡ (a’)^{−1}c’(\mod b’)$</p>
<p>综上,任意的线性同余方程总可以判定为无解,或化为 $x \equiv a(\mod m)$ 的形式。</p>
<hr>
<h2 id="中国剩余定理"><a href="#中国剩余定理" class="headerlink" title="中国剩余定理"></a>中国剩余定理</h2><p>对于同余方程组 $x \equiv a_i(\mod m_i)(i = 1\dots n)$,</p>
<p>若 $m_i$ 两两互质,则 $x$ 在 $\mod M$ 下有唯一解。这里 $M = m_1m_2\dots m_n$</p>
<h3 id="计算方法"><a href="#计算方法" class="headerlink" title="计算方法"></a>计算方法</h3><ol>
<li>计算所有模数的积 $M$</li>
<li>对于第 $i$ 个方程<ol>
<li>计算 $n_i = \frac{M}{m_i}$</li>
<li>因为 $\gcd(n_i,m_i) = 1$,所以 $n_i$ 关于 $m_i$ 的逆元 $t_i$ 存在,求出 $t_i$</li>
<li>计算 $c_i = n_i \times t_i$ </li>
</ol>
</li>
<li>方程组的唯一解为 $a = \sum_{i = 1}^k a_ic_i (\mod n)$</li>
</ol>
<h3 id="代码-1"><a href="#代码-1" class="headerlink" title="代码"></a>代码</h3><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">CRT</span><span class="params">(<span class="keyword">const</span> <span class="keyword">int</span> a[],<span class="keyword">const</span> <span class="keyword">int</span> m[],<span class="keyword">int</span> n)</span> </span>&#123;</span><br><span class="line">    <span class="keyword">int</span> M = <span class="number">1</span>,ans = <span class="number">0</span>;</span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">1</span>;i &lt;= n;++i) M *= m[i];</span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">1</span>;i &lt;= n;++i) &#123;</span><br><span class="line">        <span class="keyword">int</span> ni = M / m[i],ti = inv(ni,m[i]);</span><br><span class="line">        ans = (ans + a[i] *  ni * ti) % M;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> ans;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h3 id="应用"><a href="#应用" class="headerlink" title="应用"></a>应用</h3><p>某些计数问题或数论问题给出的模数不是质数 </p>
<p>但是对其质因数分解会发现它没有平方因子,也就是该模数是由一些不重复的质数相乘得到。</p>
<p>那么我们可以分别对这些模数进行计算,最后用 CRT 合并答案。</p>
<hr>
<h2 id="Lucas-定理"><a href="#Lucas-定理" class="headerlink" title="Lucas 定理"></a>Lucas 定理</h2><script type="math/tex; mode=display">\binom{n}{m}\bmod p = \binom{\left\lfloor n/p \right\rfloor}{\left\lfloor m/p\right\rfloor}\cdot\binom{n\bmod p}{m\bmod p}\bmod p</script><hr>
<h2 id="欧拉函数-varphi"><a href="#欧拉函数-varphi" class="headerlink" title="欧拉函数 $\varphi$"></a>欧拉函数 $\varphi$</h2><p>欧拉函数 $\varphi$ (Euler’s totient function)</p>
<p>$\varphi (n)$ 定义为 $[1, n]$ 中与 $n$ 互质的数的个数</p>
<p>例：$\varphi (1) = 1, \varphi (2) = 1, \varphi (6) = 2, \varphi (8) = 4$</p>
<p>若 $p$ 为质数,显然 $\varphi (p) = p - 1$</p>
<h3 id="性质-1"><a href="#性质-1" class="headerlink" title="性质"></a>性质</h3><ul>
<li><p>欧拉函数是<strong>积性函数</strong></p>
<p> 若 $\gcd (a,b) = 1$, $\varphi(ab) = \varphi(a) \times \varphi(b)$</p>
<p> 证明：</p>
<p> 首先令 $S(n)$ 为 $[1,n]$ 中与 $n$ 互质的数的集合</p>
<p> 任取 $S(a),S(b)$ 中的数 $a_0,b_0$</p>
<p> 考虑一个线性同余方程组</p>
<script type="math/tex; mode=display">
 \begin{cases}
     \ x \equiv a_0 (\mod a)\\
     \ x \equiv b_0 (\mod b)
 \end{cases}</script><p> 则根据中国剩余定理有 $x \equiv c_0(\mod ab)$ </p>
<p> 可以证明 $\gcd(c_0,a_0) = \gcd(c_0,b_0) = 1$</p>
<p> 所以 $\gcd(c_0,ab) = 1,c_0 \in S(ab)$</p>
<p> 如果反过来,任取 $S(ab)$ 中一个数 $c_0$,那么设 $a_0 = c_0 \mod a,b_0 = c_0 \mod b$</p>
<p> 这样可以证明有 $a_0 \in S(a),b_0 \in S(b)$</p>
<p> 因此,$|S(ab)| = |S(a)| \times |S(b)|$ </p>
<p> 也就是 $\varphi(ab) = \varphi(a) \times \varphi(b)$</p>
</li>
<li><p>若 $n = p ^ k$,则有 $\varphi(n) = n(1-\frac{1}{p})$</p>
<p>  证明：设 $x$ 为满足 $\gcd(x,p^k) &gt; 1$ 的整数,此时 $p | x$</p>
<p>  则这样的 $x$ 有$\frac{n}{p}$ 个,所以 $\varphi(n) = n - \frac{n}{p} = n(1-\frac{1}{p})$</p>
</li>
<li><p>若 $n$ 所有<strong>不同</strong>的质因子为 $p_1,p_2 \dots p_n$</p>
<p>  则 $\varphi(n) = n(1 - \frac{1}{p_1}) \times (1 - \frac{1}{p_2}) \dots (1 - \frac{1}{p_n})$</p>
<p>  证明：把 $n$ 拆成 $p_i ^{a_i}$ 用上面那个就整完了。</p>
</li>
</ul>
<p>根据这些性质,我们可以通过质因子分解求出 $\varphi(n)$,时间复杂度 $O(\sqrt{n})$</p>
<h3 id="代码-2"><a href="#代码-2" class="headerlink" title="代码"></a>代码</h3><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">phi</span><span class="params">(<span class="keyword">int</span> x)</span> </span>&#123;</span><br><span class="line">    <span class="keyword">int</span> ans = x;</span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">2</span>;i * i &lt;= x;++i) &#123;</span><br><span class="line">        <span class="keyword">if</span> (x % i == <span class="number">0</span>) &#123;</span><br><span class="line">            <span class="keyword">while</span> (x % i == <span class="number">0</span>) x *= i;</span><br><span class="line">            ret = ret / i * (i - <span class="number">1</span>);<span class="comment">//这里等价于刚才的1 - 1/p</span></span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">if</span> (x &gt; <span class="number">1</span>) ret = ret / x * (x - <span class="number">1</span>);</span><br><span class="line">    <span class="keyword">return</span> ret;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<hr>
<h2 id="欧拉定理"><a href="#欧拉定理" class="headerlink" title="欧拉定理"></a>欧拉定理</h2><p>若 $\gcd(a,n) = 1$, 则 $a ^ {\varphi(n)} \equiv 1(\mod n)$</p>
<h3 id="证明-1"><a href="#证明-1" class="headerlink" title="证明"></a>证明</h3><p>取 $\varphi(n)$ 个与 $n$ 互质且互不同余的整数构成一个集合 $S = \{a_1,a_2\dots a_{\varphi(n)}\}$ 又称模 $n$ 的简化剩余系。</p>
<p>考虑集合 $S’ = {pa_1,pa_2,\dots,pa_{\varphi(n)}}$, 显然 $S’$ 也是一个模 $n$ 的简化剩余系</p>
<p>这样如果把每个元素都对 $n$ 取模,则有 $S = S’$</p>
<p>所以可以得 $a_1,a_2\dots a_{\varphi(n)} \equiv pa_1,pa_2,\dots,pa_{\varphi(n)}(\mod n)$</p>
<p>将 $a_1,a_2\dots a_{\varphi(n)}$ 约掉就有 $p ^ {\varphi} \equiv 1 (\mod n)$</p>
<h3 id="应用-1"><a href="#应用-1" class="headerlink" title="应用"></a>应用</h3><h4 id="利用欧拉定理求逆元"><a href="#利用欧拉定理求逆元" class="headerlink" title="利用欧拉定理求逆元"></a>利用欧拉定理求逆元</h4><p>$a \times a^{\varphi(n)-1}\equiv 1(\mod n)$ </p>
<p>如果是质数,则有 $a \times a^{n-2} \equiv 1(\mod n)$</p>
<p>快速幂实现。</p>
<h4 id="快速幂缩小指数"><a href="#快速幂缩小指数" class="headerlink" title="快速幂缩小指数"></a>快速幂缩小指数</h4><p>例：求 $7 ^ {222} (\mod 10)$</p>
<p>解：</p>
<script type="math/tex; mode=display">
\begin{aligned}
    &\because \gcd(7,10) = 1\\
    &\therefore 7^{\varphi(10)} = 7 ^ 5\equiv 1 (\mod 10)\\
    &\therefore 7^{222} \equiv 7 ^ {222 \mod 5} = 49 \equiv 9 (\mod 10)
\end{aligned}</script><p>当 $\gcd(a,n) &gt; 1$ 时,我们有 $a^{\varphi(p)} \equiv a^{2\varphi(p)} (\mod n)$</p>
<p>推论：当 $b \geq \varphi(n)$ 时,$a ^ b \equiv a ^ {b \mod \varphi(n) + \varphi(n)} (\mod n)$</p>

    </div>

    
    
    

      <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/%E6%95%B0%E8%AE%BA/" rel="tag"># 数论</a>
              <a href="/tags/%E6%95%B0%E5%AD%A6/" rel="tag"># 数学</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2020/07/31/Luogu2020SC1/" rel="prev" title="洛谷 2020 提高组夏令营 模拟赛 1 赛后补题">
      <i class="fa fa-chevron-left"></i> 洛谷 2020 提高组夏令营 模拟赛 1 赛后补题
    </a></div>
      <div class="post-nav-item">
    <a href="/2020/08/05/LuoguP2303/" rel="next" title="Luogu P2303 [SDOI2012] Longge 的问题 解题报告">
      Luogu P2303 [SDOI2012] Longge 的问题 解题报告 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          
    <div class="comments" id="valine-comments"></div>

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#整除"><span class="nav-number">1.</span> <span class="nav-text">整除</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#性质："><span class="nav-number">1.1.</span> <span class="nav-text">性质：</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#质数与合数"><span class="nav-number">2.</span> <span class="nav-text">质数与合数</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#质因数分解"><span class="nav-number">3.</span> <span class="nav-text">质因数分解</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#带余除法、同余"><span class="nav-number">4.</span> <span class="nav-text">带余除法、同余</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#性质"><span class="nav-number">4.1.</span> <span class="nav-text">性质</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#推论"><span class="nav-number">4.2.</span> <span class="nav-text">推论</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#最大公约数-Greatest-Common-Divisor"><span class="nav-number">5.</span> <span class="nav-text">最大公约数(Greatest Common Divisor)</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#性质：-1"><span class="nav-number">5.1.</span> <span class="nav-text">性质：</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#欧几里得算法"><span class="nav-number">6.</span> <span class="nav-text">欧几里得算法</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#裴蜀定理"><span class="nav-number">7.</span> <span class="nav-text">裴蜀定理</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#证明"><span class="nav-number">7.1.</span> <span class="nav-text">证明</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Exgcd"><span class="nav-number">8.</span> <span class="nav-text">Exgcd</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#证明："><span class="nav-number">8.1.</span> <span class="nav-text">证明：</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#代码"><span class="nav-number">8.2.</span> <span class="nav-text">代码</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#拓展"><span class="nav-number">8.3.</span> <span class="nav-text">拓展</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#逆元"><span class="nav-number">9.</span> <span class="nav-text">逆元</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#求逆元"><span class="nav-number">9.1.</span> <span class="nav-text">求逆元</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#线性同余方程"><span class="nav-number">10.</span> <span class="nav-text">线性同余方程</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#中国剩余定理"><span class="nav-number">11.</span> <span class="nav-text">中国剩余定理</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#计算方法"><span class="nav-number">11.1.</span> <span class="nav-text">计算方法</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#代码-1"><span class="nav-number">11.2.</span> <span class="nav-text">代码</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#应用"><span class="nav-number">11.3.</span> <span class="nav-text">应用</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Lucas-定理"><span class="nav-number">12.</span> <span class="nav-text">Lucas 定理</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#欧拉函数-varphi"><span class="nav-number">13.</span> <span class="nav-text">欧拉函数 $\varphi$</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#性质-1"><span class="nav-number">13.1.</span> <span class="nav-text">性质</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#代码-2"><span class="nav-number">13.2.</span> <span class="nav-text">代码</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#欧拉定理"><span class="nav-number">14.</span> <span class="nav-text">欧拉定理</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#证明-1"><span class="nav-number">14.1.</span> <span class="nav-text">证明</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#应用-1"><span class="nav-number">14.2.</span> <span class="nav-text">应用</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#利用欧拉定理求逆元"><span class="nav-number">14.2.1.</span> <span class="nav-text">利用欧拉定理求逆元</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#快速幂缩小指数"><span class="nav-number">14.2.2.</span> <span class="nav-text">快速幂缩小指数</span></a></li></ol></li></ol></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="Doubeecat"
      src="/images/logo.jpg">
  <p class="site-author-name" itemprop="name">Doubeecat</p>
  <div class="site-description" itemprop="description"></div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">35</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">4</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">41</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="https://github.com/doubeecat" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;doubeecat" rel="noopener" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
      <span class="links-of-author-item">
        <a href="mailto:doubeecat@qq.com" title="E-Mail → mailto:doubeecat@qq.com" rel="noopener" target="_blank"><i class="fa fa-envelope fa-fw"></i>E-Mail</a>
      </span>
      <span class="links-of-author-item">
        <a href="https://weibo.com/5884458071" title="Weibo → https:&#x2F;&#x2F;weibo.com&#x2F;5884458071" rel="noopener" target="_blank"><i class="fab fa-weibo fa-fw"></i>Weibo</a>
      </span>
  </div>


  <div class="links-of-blogroll motion-element">
    <div class="links-of-blogroll-title"><i class="fa fa-link fa-fw"></i>
      Links
    </div>
    <ul class="links-of-blogroll-list">
        <li class="links-of-blogroll-item">
          <a href="https://oierwanhong.cc/" title="https:&#x2F;&#x2F;oierwanhong.cc" rel="noopener" target="_blank">Wh's Blog</a>
        </li>
        <li class="links-of-blogroll-item">
          <a href="https://blog.csdn.net/weixin_42750325" title="https:&#x2F;&#x2F;blog.csdn.net&#x2F;weixin_42750325" rel="noopener" target="_blank">Young_Zn_Cu's Blog</a>
        </li>
    </ul>
  </div>

      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 2019 – 
  <span itemprop="copyrightYear">2021</span>
  <span class="with-love">
    <i class="fa fa-battery-full"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Doubeecat</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-chart-area"></i>
    </span>
    <span title="站点总字数">89k</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
    <span title="站点阅读时长">1:21</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Gemini</a> 强力驱动
  </div>

        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    <span class="post-meta-item" id="busuanzi_container_site_uv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-user"></i>
      </span>
      <span class="site-uv" title="总访客量">
        <span id="busuanzi_value_site_uv"></span>
      </span>
    </span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item" id="busuanzi_container_site_pv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-eye"></i>
      </span>
      <span class="site-pv" title="总访问量">
        <span id="busuanzi_value_site_pv"></span>
      </span>
    </span>
</div>








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/pisces.js"></script>


<script src="/js/next-boot.js"></script>




  















  

  
      

<script>
  if (typeof MathJax === 'undefined') {
    window.MathJax = {
      loader: {
        source: {
          '[tex]/amsCd': '[tex]/amscd',
          '[tex]/AMScd': '[tex]/amscd'
        }
      },
      tex: {
        inlineMath: {'[+]': [['$', '$']]},
        tags: 'ams'
      },
      options: {
        renderActions: {
          findScript: [10, doc => {
            document.querySelectorAll('script[type^="math/tex"]').forEach(node => {
              const display = !!node.type.match(/; *mode=display/);
              const math = new doc.options.MathItem(node.textContent, doc.inputJax[0], display);
              const text = document.createTextNode('');
              node.parentNode.replaceChild(text, node);
              math.start = {node: text, delim: '', n: 0};
              math.end = {node: text, delim: '', n: 0};
              doc.math.push(math);
            });
          }, '', false],
          insertedScript: [200, () => {
            document.querySelectorAll('mjx-container').forEach(node => {
              let target = node.parentNode;
              if (target.nodeName.toLowerCase() === 'li') {
                target.parentNode.classList.add('has-jax');
              }
            });
          }, '', false]
        }
      }
    };
    (function () {
      var script = document.createElement('script');
      script.src = '//cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js';
      script.defer = true;
      document.head.appendChild(script);
    })();
  } else {
    MathJax.startup.document.state(0);
    MathJax.texReset();
    MathJax.typeset();
  }
</script>

    

  


<script>
NexT.utils.loadComments(document.querySelector('#valine-comments'), () => {
  NexT.utils.getScript('//unpkg.com/valine/dist/Valine.min.js', () => {
    var GUEST = ['nick', 'mail', 'link'];
    var guest = 'nick,mail,link';
    guest = guest.split(',').filter(item => {
      return GUEST.includes(item);
    });
    new Valine({
      el         : '#valine-comments',
      verify     : false,
      notify     : false,
      appId      : '6CGcUDbuD17aESA6Abl5FcK8-gzGzoHsz',
      appKey     : 'dopf8aMzWSSVJbvbge6BmWxi',
      placeholder: "Just go go",
      avatar     : 'mm',
      meta       : guest,
      pageSize   : '10' || 10,
      visitor    : false,
      lang       : '' || 'zh-cn',
      path       : location.pathname,
      recordIP   : false,
      serverURLs : ''
    });
  }, window.Valine);
});
</script>

</body>
</html>
